package com.neusoft.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.neusoft.model.entity.Emp;
import com.neusoft.service.EmpService;

@Controller //把当前类注册给SpringMVC容器,作为控制器组件
@RequestMapping("/Emp")
public class EmpController {
	
	@Autowired
	EmpService empService;
	
	@RequestMapping("/loadEmpByEmpno")
	public ModelAndView loadEmpByEmpno(Integer empno){
		//调用service
		Emp emp = empService.loadEmpByEmpno(empno);
		
		ModelAndView mav = new ModelAndView();
		mav.addObject("emp", emp);
		mav.setViewName("/index.jsp");
		return mav;
	}
	
	@RequestMapping("/removeEmp")
	public String removeEmp(Integer empno){
		empService.removeEmp(empno);
		return "/index.jsp";
	}
	
}
